package com.novabluetooth.services.lbxd;

import java.io.FileInputStream;
import java.io.FileNotFoundException;

import com.health.R;

import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.view.Window;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

/**
 * 展示图片
 * 
 * @author nova
 *
 */
public class ShowPicActivity extends Activity {

	private ImageView imgResult;

	private Button btn_back;
	private Button btn_up;

	private TextView title;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		this.requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.lbxd_show_jpg);
		initView();
		setListens();
	}

	private void initView() {
		imgResult = (ImageView) findViewById(R.id.show_img);

		btn_back = (Button) findViewById(R.id.btn_back);
		btn_up = (Button) findViewById(R.id.btn_up);
		btn_up.setVisibility(View.GONE);

		title = (TextView) findViewById(R.id.title);
		title.setText("心电采集结果");

		//
		String url = getIntent().getStringExtra("JPG_URL");
		Log.w("ttt", url);
		// String url="/storage/emulated/0/ECGDATA/JPEG/-20160315132210.jpeg";
		if (!TextUtils.isEmpty(url) ) {
			Bitmap bitmap = getLocalBitmap(url);
			imgResult.setImageBitmap(bitmap);
		}

	}

	private void setListens() {
		btn_back.setOnClickListener(new View.OnClickListener() {

			@Override
			public void onClick(View v) {
				ShowPicActivity.this.finish();
			}
		});
	}

	public Bitmap getLocalBitmap(String url) {

		try {
			FileInputStream fis = new FileInputStream(url);
			return BitmapFactory.decodeStream(fis);
		} catch (FileNotFoundException e) {
			e.printStackTrace();
			return null;
		}
	}

}